<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
	<head>
		<title>创建订单信息</title>
		<LINK href="<%=request.getContextPath()%>/css/cssCn.css"
			type="text/css" rel="stylesheet">
		<%@ include file="/comm.jsp"%>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">

		<style type="text/css">
<!--
fieldset {
	padding: 10px;
	margin: 10px;
	width: 100%;
	color: #333;
}

legend {
	color: #06c;
	font-weight: 800;
	background: #fff;
}

#order_save label { width: 250px; }
#order_save label.error, #order_save input.submit { margin-left: 253px; }
#signupForm { width: 670px; }
#signupForm label.error {
	margin-left: 10px;
	width: auto;
	display: inline;
}
#newsletter_topics label.error {
	display: none;
	margin-left: 103px;
}

-->
</style>

<script>

$().ready(function() {
	// validate signup form on keyup and submit
	$("#order_save").validate({
		rules: {
			amount: "required",
			seqLen: "required",
			trademark: {
				required: false,
				minlength: 3
			}			
		},
		messages: {
			firstname: "请输入订购数量",
			seqLen: "请输入封条编码位数",
			trademark: {
				minlength: "请至少输入3位商标信息"
			}			
		}
	});
});

	function ReCaculate(orderNum){
		//验证输入值是否合法(正整数)
		if(!isNumber(orderNum)){
			$d("amountError").innerHTML="请输入正确的订购数量";
			return;
		}
		//判断订购数量必须大于等于最小订购数量
		var minOrderNum=$d("hdfMinOrderNum").value;
		if(orderNum<minOrderNum)
		{
			$d("amountError").innerHTML="订购数量不能小于"+minOrderNum;
			return;
		}
		//更新赚送积分值及订单总金额
		var price=$d("hdfPrice").value;
		var score=$d("hdfScore").value;
		var discount=$d("hdfDiscount").value;
		
		var totalprice=price * orderNum * discount;
		var totalscore=score * orderNum;
		$d("totalprice").innerHTML=totalprice;
		$d("totalscore").innerHTML=totalscore;
		$d("amountError").innerHTML="";
	}
</script>

	</head>
	<body>
		<%@ include file="/messages.jsp"%>
		<s:form name="formpage" action="order_save" namespace="/seal">
			<s:token>
			</s:token>
			<div>
				<table width="100%" class="tb_input" border="0" cellpadding="0"
					cellspacing="1">
					<tr>
						<td width="200px" valign="top">
							<table width="100%" class="tb_input" border="0" cellpadding="0"
								cellspacing="1">
								<tr>
									<td>
										商品信息
									</td>
								</tr>
								<tr>
									<td align="center">
										<IMG height="180" width="180" alt="商品图片"
											src="<%=request.getContextPath()%>/upload/seal/${product.image1}">
									</td>
								</tr>
								<tr>
									<td>
										<table border="0" cellpadding="0" cellspacing="1">
											<tr>
												<td align="right">
													<input type="hidden" id="productId" name="orderInfo.productId" value="${orderInfo.productId}" />
													商品名称：
												</td>
												<td>
													${orderInfo.productName}
												</td>
											</tr>
											<tr>
												<td align="right">
													型号：
												</td>
												<td>
													${orderInfo.type}
												</td>
											</tr>
											<tr>
												<td align="right">
													颜色：
												</td>
												<td>
													<input type="hidden" name="orderInfo.color" value="${orderInfo.color}" />
													${orderInfo.color}
												</td>
											</tr>
											<tr>
												<td align="right">
													单价：
												</td>
												<td>
													<input type="hidden" id="hdfPrice" value="${orderInfo.price}" />
													<input type="hidden" id="hdfScore" value="${orderInfo.score}" />
													<input type="hidden" id="hdfDiscount" name="orderInfo.discount" value="${orderInfo.discount}" />
													${orderInfo.price}
													<s:if test='"RMB"==#request.orderInfo.currtype'>
														元
													</s:if>
													<s:elseif test='"USD"==#request.orderInfo.currtype'>
														美元
													</s:elseif>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
						<td valign="top">
							<div>
								<table width="100%" class="tb_input" border="0" cellpadding="0"
									cellspacing="1">
									<tr>
										<td colspan="2">
											确认收货地址
										</td>
									</tr>
									<tr>
										<td align="right" width="110">
											账户代码：
										</td>
										<td>
											${userId }
										</td>
									</tr>
									<tr>
										<td align="right" width="110">
											收货人姓名：
										</td>
										<td>
											<input name="orderInfo.userName" type="text" maxlength="20"
												size="18" value="${orderInfo.userName }" />
										</td>
									</tr>
									<tr>
										<td align="right">
											手机：
										</td>
										<td>
											<input name="orderInfo.cellphone" type="text" maxlength="20"
												size="18" value="${orderInfo.cellphone }" />
										</td>
									</tr>
									<tr>
										<td align="right">
											电话：
										</td>
										<td>
											<input name="orderInfo.countryCode" type="text" maxlength="5"
												size="4" value="${orderInfo.countryCode }" />
											<input name="orderInfo.regionCode" type="text" maxlength="6"
												size="6" value="${orderInfo.regionCode }" />
											<input name="orderInfo.telephone" type="text" maxlength="15"
												size="16" value="${orderInfo.telephone }" />
										</td>
									</tr>
									<tr>
										<td align="right">
											邮政编码：
										</td>
										<td>
											<input name="orderInfo.postcode" type="text" maxlength="20"
												size="10" value="${orderInfo.postcode }" />
										</td>
									</tr>
									<tr>
										<td align="right">
											收货地址：
										</td>
										<td>
											<textarea name="orderInfo.address" id="address" rows="3"
												cols="50">${orderInfo.address }</textarea>
										</td>
									</tr>
								</table>
							</div>
							<div>
								<table width="100%" class="tb_input" border="0" cellpadding="0"
									cellspacing="1">
									<tr>
										<td colspan="2">
											确认订购信息
										</td>
									</tr>
									<tr>
										<td align="right" width="110">
											订购数量：
										</td>
										<td>
											<input id="amount" name="orderInfo.amount" type="text" maxlength="8"
												size="10" value="${orderInfo.amount }"
												onPropertyChange="ReCaculate(this.value);" />
											(最小订购数量${product.minOrderNum}条)
											<input type="hidden" id="hdfMinOrderNum" value="${product.minOrderNum}" />
											<span id="amountError"></span>
										</td>
									</tr>
									
									<tr>
										<td align="right">
												编码位数：
											</td>
											<td>
												<input id="sqlLen" type="text" name="orderInfo.seqLen" size="10" maxlength="10"
													value="${orderInfo.seqLen }" />
											</td>
									</tr>
									<tr>
											<td align="right" width="110">
												商标：
											</td>
											<td>
												<input id="trademark" type="text" size="10" maxlength="10"	name="orderInfo.trademark" value="${orderInfo.trademark }"/>
											</td>
											
									</tr>
										<tr>
											<td  align="right" rowspan="2">
												封条编码规则：
											</td>
											<td>
												<input type="radio"  id="roleType1"
													name="orderInfo.roleType" value="01"/>
												全数字
											</td>
										</tr>
										<tr>
											<td>
											<input type="radio" size="15" maxlength="15" id="roleType2"
													name="orderInfo.roleType" value="02"/>
												字母前辍
												<!-- 封条上的字母全部转成大写 -->
												<input id="seqChar" type="text" size="5" maxlength="4" name="orderInfo.seqChar" title="字母前辍"
													value="${orderInfo.seqChar }";
												/>
											</td>
									</tr>
									
									<tr>
										<td align="right">
											订单留言：
										</td>
										<td>
											<textarea name="orderInfo.message" id="message" rows="4"
												cols="50">${orderInfo.message }</textarea>
										</td>
									</tr>
								</table>
							</div>
							<div>
								可获积分：
								<span id="totalscore"> ${orderInfo.totalscore} </span> 点 订单金额：
								<span id="totalprice"> ${orderInfo.totalprice} </span>
								<s:if test='"RMB"==#request.orderInfo.currtype'>
									元
								</s:if>
								<s:elseif test='"USD"==#request.orderInfo.currtype'>
									美元
								</s:elseif>
								<br />
								<br />
								<input type="submit" id="ok" name="ok" value=" 确 定 "
									class="button" />
							</div>
						</td>
					</tr>
				</table>
			</div>
		</s:form>
	</body>
</html>
